# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: AlexWMF <alexxwmf@gmail.com>

_realname=libsamplerate
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.1.9
pkgrel=1
pkgdesc="Secret Rabbit Code (aka libsamplerate) is a Sample Rate Converter for audio (mingw-w64)"
arch=('any')
license=('BSD-2-Clause')
url="http://www.mega-nerd.com"
depends=("${MINGW_PACKAGE_PREFIX}-libsndfile"
         "${MINGW_PACKAGE_PREFIX}-fftw")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=(staticlibs !buildflags)
source=("http://www.mega-nerd.com/SRC/${_realname}-${pkgver}.tar.gz"
        'libsamplerate-0.1.9.patch')
sha256sums=('0a7eb168e2f21353fb6d84da152e4512126f7dc48ccb0be80578c565413444c1'
            'e29acb3631ffae03a7cd056ee7b8652a12b2bd9ee79c06ffef450e3dc4c89457')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "../libsamplerate-0.1.9.patch"
}

build() {
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST}

  make ${MAKEFLAGS} # VERBOSE=1
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make -j1 DESTDIR="${pkgdir}" install
}
